package com.lancoo.znbkxx.teacher.aibkTestCoach.paperToPersonalAnalysis.aibkAnalysisZW

import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.lancoo.znbkxx.teacher.R
import com.lancoo.znbkxx.teacher.aibkTestCoach.auidoPlayer.AudioTracker
import com.lancoo.znbkxx.teacher.aibkTestCoach.kBase.KBaseFragment
import com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.entity.PaperPerAnalysisInfor

class AnalysisFragmentParentZw (
        val activity: AppCompatActivity,
        val paperPerAnalysisInfor: PaperPerAnalysisInfor,
        val index_A:Int,
        val index_B:Int,
        val index_C:Int
) : KBaseFragment() {

    override fun createLayout(): Int {
        return R.layout.aibk_include_analysis_ques_answer_zw_view
    }

    override fun initView(view: View?) {

        //加载作答区域
        val writtingAnswerType = paperPerAnalysisInfor.TypeList[index_A].QuesAnswerList[index_B].ChildAnswerList[0].WrittingAnswerType
        if(writtingAnswerType == 1){
            val fragment = AnalysisChildFargmentWord(activity,paperPerAnalysisInfor,index_A,index_B,index_C)
            childFragmentManager.beginTransaction().add(R.id.Fragment, fragment).commit()
        }else if(writtingAnswerType == 2){
            audioTracker = AudioTracker()
            audioTracker!!.createAudioTrack()
            val fragment = AnalysisChildFargmentAudio(activity,paperPerAnalysisInfor,index_A,index_B,index_C,audioTracker!!)
            childFragmentManager.beginTransaction().add(R.id.Fragment, fragment).commit()
        }else if(writtingAnswerType == 3){
            val fragment = AnalysisChildFargmentImage(activity,paperPerAnalysisInfor,index_A,index_B,index_C)
            childFragmentManager.beginTransaction().add(R.id.Fragment, fragment).commit()
        }
    }

    override fun onPause() {
        super.onPause()
        audioTrackerStop()
    }
}